{% extends 'usercenter_base.html' %}
{% load staticfiles %}

{% block title %}
    我的课程- 慕学在线网
{% endblock %}

{% block custom_bread %}
    <section>
        <div class="wp">
            <ul class="crumbs">
                <li><a href="{% url 'index' %}">首页</a>></li>
                <li><a href="{% url 'users:userinfo' %}">个人中心</a>></li>
                <li>我的收藏</li>
            </ul>
        </div>
    </section>
{% endblock %}

{% block right_form %}
    <div class="right">
            <div class="personal_des Releasecont">
                <div class="head">
                    <h1>我的收藏</h1>
                </div>
            </div>

            <div class="personal_des permessage">
                <div class="head">
                    <ul class="tab_header messagehead">
                        <li class="active"><a href="{% url 'users:my_fav_org' %}">课程机构</a></li>
                        <li><a href="{% url 'users:my_fav_teacher' %}">授课教师 </a></li>
                        <li><a href="{% url 'users:my_fav_course' %}">公开课程</a></li>
                    </ul>
                </div>
                <div class="messagelist">
                    {% for org in org_list %}
                        <div class="messages butler_list company company-fav-box">
                            <dl class="des fr">
                                <dt>
                                    <a href="{% url 'organization:home' org.id %}">
                                        <img width="160" height="90" src="{{ org.image.url }}" alt=""/>
                                    </a>
                                </dt>
                                <dd>
                                    <h1><a href="{% url 'organization:home' org.id %}">{{ org.name }}</a></h1>
                                    <div class="pic fl" style="width:auto;">
                                        {% if org.is_auth %}
                                            <img src="{% static 'images/authentication.png' %}" alt=""/>
                                        {% endif %}
                                        {% if org.is_gold %}
                                            <img src="{% static 'images/gold.png' %}" alt=""/>
                                        {% endif %}
                                    </div>
                                    <span class="c8 clear">{{ org.address }}</span>
                                    <div class="delete jsDeleteFav_org" data-favid="{{ org.id }}"></div>
                                </dd>
                            </dl>
                        </div>
                    {% endfor %}
                </div>
            </div>
        </div>
{% endblock %}

{% block custom_js %}
    <script type="text/javascript">
        $('.jsDeleteFav_org').on('click', function () {
            var _this = $(this),
                favid = _this.attr('data-favid');
            $.ajax({
                cache: false,
                type: "POST",
                url: "{% url 'operation:fav' %}",
                data: {
                    fav_type: 2,
                    fav_id: favid,
                    csrfmiddlewaretoken: '{{ csrf_token }}'
                },
                async: true,
                success: function (data) {
                    _this.parent().parent().parent().remove()
                }
            });
        });
    </script>
{% endblock %}